﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using DBTMDT.Dal;
namespace DBTMDT.Biz
{
    class BizSanPham
    {
        public int IDSanPham { get; set; }
        public string MaSanPham { get; set; }
        public decimal GiaThiTruong { get; set; }
        public string Processor { get; set; }
        public string Ram { get; set; }
        public string Display { get; set; }
        public string Other { get; set; }
        public int Weight { get; set; }
        public string OS { get; set; }
        public Image HinhAnh { get; set; }
        public BizLoaiSanPham LoaiSanPham { get; set; }

        public BizSanPham()
        {
            this.IDSanPham = -1;
            this.LoaiSanPham = new BizLoaiSanPham();
        }

        public BizSanPham(int IDSanPham, string MaSanPham, decimal GiaThiTruong, string Processor, string Ram, string Display, string Other, int Weight, string OS, BizLoaiSanPham LoaiSanPham, Image HinhAnh)
        {
            this.IDSanPham = IDSanPham;
            this.MaSanPham = MaSanPham;
            this.GiaThiTruong = GiaThiTruong;
            this.Processor = Processor;
            this.Ram = Ram;
            this.Display = Display;
            this.Other = Other;
            this.Weight = Weight;
            this.OS = OS;
            this.LoaiSanPham = LoaiSanPham;
            this.HinhAnh = HinhAnh;        
            
        }

        public BizSanPham(string MaSanPham, decimal GiaThiTruong, string Processor, string Ram, string Display, string Other, int Weight, string OS, BizLoaiSanPham LoaiSanPham, Image HinhAnh)
        {
            
            this.MaSanPham = MaSanPham;
            this.GiaThiTruong = GiaThiTruong;
            this.Processor = Processor;
            this.Ram = Ram;
            this.Display = Display;
            this.Other = Other;
            this.Weight = Weight;
            this.OS = OS;
            this.LoaiSanPham = LoaiSanPham;
            this.HinhAnh = HinhAnh;

        }

        public void Save()
        {   
           if(this.IDSanPham == -1)
               this.IDSanPham = DalSanPham.Insert(this);
           else
               DalSanPham.Update(this);        
        
        }
    }
}
